// Code generated by smithy-go-codegen DO NOT EDIT.

package s3

import (
	
	
	
	
	awsmiddleware 
	
	s3cust 
	
	smithy 
	smithyxml 
	smithyio 
	
	smithyhttp 
	
)

// Returns the Region the bucket resides in. You set the bucket's Region using the
// LocationConstraint request parameter in a CreateBucket request. For more
// information, see CreateBucket
// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html). To use
// this implementation of the operation, you must be the bucket owner. To use this
// API against an access point, provide the alias of the access point in place of
// the bucket name. The following operations are related to GetBucketLocation:
//
// *
// GetObject
// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html)
//
// *
// CreateBucket
// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html)
func ( *Client) ( context.Context,  *GetBucketLocationInput,  ...func(*Options)) (*GetBucketLocationOutput, error) {
	if  == nil {
		 = &GetBucketLocationInput{}
	}

	, ,  := .invokeOperation(, "GetBucketLocation", , , .addOperationGetBucketLocationMiddlewares)
	if  != nil {
		return nil, 
	}

	 := .(*GetBucketLocationOutput)
	.ResultMetadata = 
	return , nil
}

type GetBucketLocationInput struct {

	// The name of the bucket for which to get the location.
	//
	// This member is required.
	Bucket *string

	// The account ID of the expected bucket owner. If the bucket is owned by a
	// different account, the request fails with the HTTP status code 403 Forbidden
	// (access denied).
	ExpectedBucketOwner *string

	noSmithyDocumentSerde
}

type GetBucketLocationOutput struct {

	// Specifies the Region where the bucket resides. For a list of all the Amazon S3
	// supported location constraints by Region, see Regions and Endpoints
	// (https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region). Buckets in
	// Region us-east-1 have a LocationConstraint of null.
	LocationConstraint types.BucketLocationConstraint

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func ( *Client) ( *middleware.Stack,  Options) ( error) {
	 = .Serialize.Add(&awsRestxml_serializeOpGetBucketLocation{}, middleware.After)
	if  != nil {
		return 
	}
	 = .Deserialize.Add(&awsRestxml_deserializeOpGetBucketLocation{}, middleware.After)
	if  != nil {
		return 
	}
	if  = addSetLoggerMiddleware(, );  != nil {
		return 
	}
	if  = awsmiddleware.AddClientRequestIDMiddleware();  != nil {
		return 
	}
	if  = smithyhttp.AddComputeContentLengthMiddleware();  != nil {
		return 
	}
	if  = addResolveEndpointMiddleware(, );  != nil {
		return 
	}
	if  = v4.AddComputePayloadSHA256Middleware();  != nil {
		return 
	}
	if  = addRetryMiddlewares(, );  != nil {
		return 
	}
	if  = addHTTPSignerV4Middleware(, );  != nil {
		return 
	}
	if  = awsmiddleware.AddRawResponseToMetadata();  != nil {
		return 
	}
	if  = awsmiddleware.AddRecordResponseTiming();  != nil {
		return 
	}
	if  = addClientUserAgent();  != nil {
		return 
	}
	if  = smithyhttp.AddErrorCloseResponseBodyMiddleware();  != nil {
		return 
	}
	if  = smithyhttp.AddCloseResponseBodyMiddleware();  != nil {
		return 
	}
	if  = swapDeserializerHelper();  != nil {
		return 
	}
	if  = swapWithCustomHTTPSignerMiddleware(, );  != nil {
		return 
	}
	if  = addOpGetBucketLocationValidationMiddleware();  != nil {
		return 
	}
	if  = .Initialize.Add(newServiceMetadataMiddleware_opGetBucketLocation(.Region), middleware.Before);  != nil {
		return 
	}
	if  = addMetadataRetrieverMiddleware();  != nil {
		return 
	}
	if  = addGetBucketLocationUpdateEndpoint(, );  != nil {
		return 
	}
	if  = addResponseErrorMiddleware();  != nil {
		return 
	}
	if  = v4.AddContentSHA256HeaderMiddleware();  != nil {
		return 
	}
	if  = disableAcceptEncodingGzip();  != nil {
		return 
	}
	if  = addRequestResponseLogging(, );  != nil {
		return 
	}
	return nil
}

type awsRestxml_deserializeOpGetBucketLocation_custom struct {
}

func (*awsRestxml_deserializeOpGetBucketLocation_custom) () string {
	return "OperationDeserializer"
}

func ( *awsRestxml_deserializeOpGetBucketLocation_custom) ( context.Context,  middleware.DeserializeInput,  middleware.DeserializeHandler) (
	 middleware.DeserializeOutput,  middleware.Metadata,  error,
) {
	, ,  = .HandleDeserialize(, )
	if  != nil {
		return , , 
	}

	,  := .RawResponse.(*smithyhttp.Response)
	if ! {
		return , , &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", .RawResponse)}
	}

	if .StatusCode < 200 || .StatusCode >= 300 {
		return , , awsRestxml_deserializeOpErrorGetBucketLocation(, &)
	}
	 := &GetBucketLocationOutput{}
	.Result = 

	var  [1024]byte
	 := smithyio.NewRingBuffer([:])
	 := io.TeeReader(.Body, )
	 := xml.NewDecoder()
	 := smithyxml.WrapNodeDecoder(, xml.StartElement{})
	 = awsRestxml_deserializeOpDocumentGetBucketLocationOutput(&, )
	if  == io.EOF {
		 = nil
	}
	if  != nil {
		var  bytes.Buffer
		io.Copy(&, )
		return , , &smithy.DeserializationError{
			Err:      fmt.Errorf("failed to decode response body, %w", ),
			Snapshot: .Bytes(),
		}
	}

	return , , 
}

// Helper to swap in a custom deserializer
func ( *middleware.Stack) error {
	,  := .Deserialize.Swap("OperationDeserializer", &awsRestxml_deserializeOpGetBucketLocation_custom{})
	if  != nil {
		return 
	}
	return nil
}

func ( string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        ,
		ServiceID:     ServiceID,
		SigningName:   "s3",
		OperationName: "GetBucketLocation",
	}
}

// getGetBucketLocationBucketMember returns a pointer to string denoting a provided
// bucket member valueand a boolean indicating if the input has a modeled bucket
// name,
func ( interface{}) (*string, bool) {
	 := .(*GetBucketLocationInput)
	if .Bucket == nil {
		return nil, false
	}
	return .Bucket, true
}
func ( *middleware.Stack,  Options) error {
	return s3cust.UpdateEndpoint(, s3cust.UpdateEndpointOptions{
		Accessor: s3cust.UpdateEndpointParameterAccessor{
			GetBucketFromInput: getGetBucketLocationBucketMember,
		},
		UsePathStyle:                   .UsePathStyle,
		UseAccelerate:                  .UseAccelerate,
		SupportsAccelerate:             true,
		TargetS3ObjectLambda:           false,
		EndpointResolver:               .EndpointResolver,
		EndpointResolverOptions:        .EndpointOptions,
		UseARNRegion:                   .UseARNRegion,
		DisableMultiRegionAccessPoints: .DisableMultiRegionAccessPoints,
	})
}